package com.eleadmin.common.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eleadmin.common.system.mapper.LeavemessageMapper;
import com.eleadmin.common.system.service.LeavemessageService;
import com.eleadmin.common.system.entity.Leavemessage;
import com.eleadmin.common.system.param.LeavemessageParam;
import com.eleadmin.common.core.web.PageParam;
import com.eleadmin.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Service实现
 *
 * @author EleAdmin
 * @since 2024-02-26 22:09:04
 */
@Service
public class LeavemessageServiceImpl extends ServiceImpl<LeavemessageMapper, Leavemessage> implements LeavemessageService {

    @Override
    public PageResult<Leavemessage> pageRel(LeavemessageParam param) {
        PageParam<Leavemessage, LeavemessageParam> page = new PageParam<>(param);
        //page.setDefaultOrder("create_time desc");
        List<Leavemessage> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<Leavemessage> listRel(LeavemessageParam param) {
        List<Leavemessage> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<Leavemessage, LeavemessageParam> page = new PageParam<>();
        //page.setDefaultOrder("create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public Leavemessage getByIdRel(Integer id) {
        LeavemessageParam param = new LeavemessageParam();
        param.setId(id);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
